import React from 'react'
import { Form, Table, Icon, Tag, Modal, Steps, Button, message, Input, Row, Col, Select, DatePicker, InputNumber, Dropdown, Menu, Badge, Upload } from 'antd'
import { DropOption } from 'components'
import styles from './List.less'
import moment from "moment"
import $ from "jquery"
import { formatDate } from "utils";

const Step = Steps.Step;
const confirm = Modal.confirm
const FormItem = Form.Item;
const Option = Select.Option;
const { TextArea } = Input;
const datas = [];
var billValue = '';
var clickOne = ''
const baseUrl = "http://file.sip.feelbang.com/files/"
const dateFormat = 'YYYY/MM/DD HH:mm:ss';

var contractorUserName = '' //承办人
var createdUserName = ''  //建档人

class ModalSelect extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			current: 0,
			value: '',
			bottons: '查看',
			previewVisible: false,
			previewImage: '',
			imgList: [],

			createdTime: "",
			notarizationAt: "",
			sleectType: "",

			showImgList:[],

			showLoading:false,

			keys:{},   //公证信息的内容
			keys1:{},  //申请人的内容
		};
	}
	showReturn() {
		const { showList } = this.props
		showList()
		this.setState({imgList:[]})
	}
	show(value) {
		const { showList, details, onEdit } = this.props
		const { validateFields, getFieldsValue } = this.props.form
		const params = getFieldsValue()
		params.state = value
		params.id = details.document.application.id
		if (params.opinion == undefined) {
			params.opinion = ''
		}
		params.type = details.document.application.type
		params.documentId = details.document.id
		onEdit(params)

	}
	bottonClick(i) {
		if (document.getElementById(i).style.display != "block") {
			document.getElementById(i).style.display = 'block'
		} else {
			document.getElementById(i).style.display = 'none'
		}
		if (this.state.bottons == '查看') {
			this.setState({ bottons: "隐藏" })
		} else {
			this.setState({ bottons: "查看" })
		}
	}
	imgClick = e => {
		this.setState({ previewVisible: true, previewImage: e.target.src })
	}
	handleCancel = () => {
		this.setState({ previewVisible: false })
	}
	onUpdateChanges = (i, info) => {
		const { imgList } = this.state
		let { fileList } = info;
		if (fileList.length > 0 && fileList[fileList.length - 1].response) {
			const paths = fileList[fileList.length - 1].response.path
			const name = "http://file.sip.feelbang.com/files/" + fileList[fileList.length - 1].response.path + "?token=" + sessionStorage.getItem("token") + "&" + "sys=1001"
			fileList.splice(fileList.length - 1, 1, { uid: fileList.length, status: 'done', url: name, urls: paths })
		}
		imgList[i] = fileList
		this.setState({ imgList, fileList, isChange: true })
	}
	bottomsClick(i) {
		clickOne = i
		this.setState({ showImg: true, showScanImg: false })
		//		var node = document.getElementById("photos")
		//		node.style.display = "block";
	}
	bottonScanClick(i) {
		clickOne = i
		this.setState({ showScanImg: true, showImg: false })
	}
	createTimeChange = (data, dateString) => {
		this.setState({ createdTime: dateString })
	}
	notarizationChange = (data, dateString) => {
		this.setState({ notarizationAt: dateString })
	}
	selectChange = (value) => {
		this.setState({ sleectType: value })
	}
	handleOpenDev = () => {
		openDev()
	}
	handleCaptureBase64 = () => {
		CaptureBase64()
	}
	handleOpenScan = () => {
		getdslist()
	}
	handleScanBase64 = () => {
		scan()
		const { showImgList } = this.state
		const baseImgs = JSON.parse(sessionStorage.getItem("sacnbase64"))
		if (baseImgs) {
			baseImgs.map((item, i) => {
				showImgList.push(<img style={{ width: 80, margin: 5 }} src={"data:image/jpg;base64," + item} />)
			})
		}
	}
	urltoFile(url, filename, mimeType){
		mimeType = mimeType || (url.match(/^data:([^;]+);/)||'')[1];
		return (fetch(url)
			.then(function(res){return res.arrayBuffer();})
			.then(function(buf){return new File([buf], filename, {type:mimeType});})
		);
	}
	handleScanUpload = () => {
		const { imgList } = this.state
		// var scanbase = sessionStorage.getItem("sacnbase64")
		this.setState({showLoading:true})
		const _this = this
		// console.log(sacnbase123)
		//data:image/png;base64,
		// var scanbases = JSON.parse(scanbase)
		if(sacnbase123.length < 1){
			setTimeout(this.setState({showLoading:false}),1000)
		}
		sacnbase123.map((item, i) => {
			let datas = new FormData();
			// let datas = new FormData();
			// var blob = this.b64toBlob(files, "jpg");
			// datas.append('file',blob)
			// console.log(blob)
				// datas.append('file',this.convertBase64UrlToBlob(item))
			// datas.append('data', "data:image/png;base64," + item)
			// datas.append('data', files)
			// console.log(this.convertsBase64UrlToBlob(files))
			// datas.append('file',this.convertBase64UrlToBlob(files))
			// datas.append('file',this.dataURLtoFile(files,"file"))
			// console.log(this.dataURLtoFile(files))
			// console.log(this.dataURLtoFile(files,"file"))
			// console.log(datas)
			// console.log(datas.append('file',this.convertBase64UrlToBlob(files)))
			// $.ajaxSetup({contentType: 'application/x-www-form-urlencoded'});
			// const img1 = "data:image/png;base64,"+files
			this.urltoFile("data:image/png;base64,"+item, 'a.gif')
                .then(function(file){
					datas.append("file", file);
			$.ajax({
				// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
				url: 'http://file.sip.feelbang.com/upload?token=' + sessionStorage.getItem("token") +"&"+ "sys=1001",
				type: 'POST',
				// dataType:"text",
				// cache: false,
						    // headers: {
							// 	"Content-type": "multipart/form-data"
							// },
				//			data:new FormData($('#uploadForm')[0]),
				data: datas,
				// scriptCharset:"utf-8",
				processData: false,
				contentType: false
			}).done(function (res) {
				const names = JSON.parse(res)
				const name = "http://file.sip.feelbang.com/files/" + names.path + "?token=" + sessionStorage.getItem("token") +"&"+ "sys=1001"
				if (imgList.length == 0) {
					imgList[clickOne] = []
				}
				imgList[clickOne].push({ uid: imgList[clickOne].length, status: 'done', url: name, urls: names.path })
				_this.setState({ test: false,showLoading:false })
				delete sacnbase123[i]
				// sessionStorage.removeItem("sacnbase64")
			}).fail(function (res) {
				console.log(res)
				_this.setState({showLoading:false})
				delete sacnbase123[i]
				// sessionStorage.removeItem("sacnbase64")
			});
		})	
		})
	}
	handleUpload = () => {
		const { imgList, fileList1, fileList2, fileList3, fileList4, fileList5 } = this.state
		this.setState({showLoading:true})
		const _this = this
		var base = sessionStorage.getItem("base64")
		let datas = new FormData();
		datas.append('data', base)
		$.ajax({
			url: 'http://file.sip.feelbang.com/upload?token=' + sessionStorage.getItem("token") +"&"+ "sys=1001",
			type: 'POST',
			cache: false,
			//		    headers: {
			//				"Content-type": "multipart/form-data"
			//			},
			//			data:new FormData($('#uploadForm')[0]),
			data: datas,
			processData: false,
			contentType: false
		}).done(function (res) {
			const names = JSON.parse(res)
			const name = "http://file.sip.feelbang.com/files/" + names.path + "?token=" + sessionStorage.getItem("token") +"&"+ "sys=1001"
			if (imgList.length == 0) {
				imgList[clickOne] = []
			}
			imgList[clickOne].push({ uid: imgList[clickOne].length, status: 'done', url: name, urls: names.path })
			_this.setState({ test: false,showLoading: false })
		}).fail(function (res) {
			console.log(res)
			_this.setState({showLoading:false})
		});

	}
	agreeClick = () => {
		const { imgList, createdTime, notarizationAt, sleectType } = this.state
		const { validateFields, getFieldsValue } = this.props.form
		const { details, updateFile } = this.props
		imgList.map((item, i) => {
			var urlss = '';
			item.map((item1, j) => {
				urlss += item1.urls + "#"
			})
			datas[i] = datas[i] + "@" + item.length + "@" + urlss
		})

		validateFields((errors) => {
			if (errors) {
				return
			}
			const params = getFieldsValue()
			billValue = '';
			datas.map((item, i) => {
				billValue += item + ","
			})
			params.createdTime = createdTime
			params.notarizationAt = notarizationAt
			if (createdTime == "") {
				params.createdTime = moment(details.document.createdTime).format("YYYY-MM-DD HH:mm:ss")

			}
			if (notarizationAt == "") {
				params.notarizationAt = moment(details.document.notarizationAt).format("YYYY-MM-DD HH:mm:ss")
				// details.document.notarizationAt
			}
			params.bill = billValue
			params.documentId = details.document.id
			params.id = details.document.application.id
			params.state = 1
			params.documentType = sleectType
			delete params.type
			let notarialMatters = ''
			let notaryNumber = ''
			let applyName = ''
			let idcard = ''
			for(let key in params){
				if(key.indexOf('notarialMatters')>=0){
					notarialMatters +=params[key]+ '#'
					// delete params[key]
				}
				if(key.indexOf('notaryNumber')>=0){
					notaryNumber +=params[key] + '#'
					// delete params[key]
				}
				if(key.indexOf('applyName')>=0){
					applyName +=params[key]+ '#'
					// delete params[key]
				}
				if(key.indexOf('idcard')>=0){
					idcard +=params[key]+ '#'
					// delete params[key]
				}
			}
			params.notarialMatters = notarialMatters
			params.notaryNumber = notaryNumber
			params.applyName = applyName
			params.idcard = idcard
			updateFile(params)
		})
	}
	disagreeClick = () => {
		const { imgList, createdTime, notarizationAt, sleectType } = this.state
		const { validateFields, getFieldsValue } = this.props.form
		const { details, updateFile1 } = this.props
		imgList.map((item, i) => {
			var urlss = '';
			item.map((item1, j) => {
				urlss += item1.urls + "#"
			})
			datas[i] = datas[i] + "@" + item.length + "@" + urlss
		})

		validateFields((errors) => {
			if (errors) {
				return
			}
			const params = getFieldsValue()
			billValue = '';
			datas.map((item, i) => {
				billValue += item + ","
			})
			params.createdTime = createdTime
			params.notarizationAt = notarizationAt
			if (createdTime == "") {
				params.createdTime = moment(details.document.createdTime).format("YYYY-MM-DD HH:mm:ss")

			}
			if (notarizationAt == "") {
				params.notarizationAt = moment(details.document.notarizationAt).format("YYYY-MM-DD HH:mm:ss")
				// details.document.notarizationAt
			}
			params.bill = billValue
			params.documentId = details.document.id
			params.id = details.document.application.id
			params.state = 2
			params.documentType = sleectType
			delete params.type
			updateFile1(params)
		})
	}
	removeForm = (k) => {
		const { form } = this.props;

		const { keys } = this.state
		delete keys[k]
		this.setState({
			keys:keys
		})
	}
	addForm = () => {
		const { form } = this.props;

		const {keys} = this.state

		keys[new Date().getTime()] = {}

		this.setState({key:keys})
	}

	removePersonForm = (k) => {
		const { form } = this.props;
		
		const { keys1 } = this.state
		delete keys1[k]
		this.setState({
			keys1:keys1
		})
	}
	addPersonForm = () => {
		const { form } = this.props;

		const {keys1} = this.state

		keys1[new Date().getTime()] = {}

		this.setState({key1:keys1})
	}
	componentDidUpdate = () => {

		const { details } = this.props
		const infoData = details

		let notarialMatters = [];
		let notaryNumber = [];
		let applyName = [];
		let idcard = [];
		let keys={}
		let keys1={}

		if(infoData){
			notarialMatters = infoData.document.notarialMatters.split("#")
			notaryNumber = infoData.document.notaryNumber.split("#")
			applyName = infoData.document.applyName.split("#")
			idcard = infoData.document.idcard.split("#")

			// notaryNumber = notaryNumber.splice(notaryNumber.length-1,1)
			// applyName = applyName.splice(applyName.length-1,1)
			// idcard = idcard.splice(idcard.length-1,1)
		}
		notarialMatters.splice(notarialMatters.length-1,1)
		applyName.splice(applyName.length-1,1)
		if(notarialMatters.length > 0){
			notarialMatters.map((item,i)=>{
				keys[String(i+1)] = {
					notarialMatters:notarialMatters[i],
					notaryNumber:notaryNumber[i],
					// applyName:applyName[i],
					// idcard:idcard[i],
				}
			})
			if(JSON.stringify(this.state.keys) == "{}"){
				this.setState({keys:keys})
			}
		}
		if(applyName.length > 0){
			applyName.map((item,i)=>{
				keys1[String(i+1)] = {
					// notarialMatters:notarialMatters[i],
					// notaryNumber:notaryNumber[i],
					applyName:applyName[i],
					idcard:idcard[i],
				}
			})
			if(JSON.stringify(this.state.keys1) == "{}"){
				this.setState({keys1:keys1})
			}
			
		}
		
	}
	render() {
		const { details, isComponent, userList, depTypes } = this.props
		const { imgList } = this.state
		if (!details) {
			return null
		}
		const infoData = details

		const userLists = [];
		var photoPage = [];
		var propss = []
		const uploadButton = (
			<div>
				<Icon type="plus" />
				<div className="ant-upload-text">上传</div>
			</div>
		);
		for (let i = 0; i < userList.length; i++) {
			userLists.push(<Option key={userList[i].userId} value={userList[i].userId}>{userList[i].username}</Option>);
		}
		const typeChild = [];
		for (let i = 0; i < depTypes.length; i++) {
			typeChild.push(<Option key={depTypes[i].id}>{depTypes[i].name}</Option>);
		}
		const { getFieldDecorator } = this.props.form
		const { previewVisible, previewImage } = this.state
		const formItemLayout = {
			labelCol: { span: 6 },
			wrapperCol: { span: 18 },
		};
		const formItemLayout1 = {
			labelCol: { span: 3 },
			wrapperCol: { span: 21 },
		};
		const formItemLayoutWithOutLabel = {
			wrapperCol: {
				xs: { span: 24, offset: 0 },
				sm: { span: 16, offset: 8 },
			},
		};
		const {keys,keys1}=this.state
		var myArry = []
		var peopleArry = []
		for(let key in keys){
			myArry.push(
				{
					'key':key,
					'notarialMatters':keys[key].notarialMatters,
					'notaryNumber':keys[key].notaryNumber,
					// 'applyName':keys[key].applyName,
					// 'idcard':keys[key].idcard
				}
			)
		}

		for(let key in keys1){
			peopleArry.push(
				{
					'key':key,
					// 'notarialMatters':keys[key].notarialMatters,
					// 'notaryNumber':keys[key].notaryNumber,
					'applyName':keys1[key].applyName,
					'idcard':keys1[key].idcard
				}
			)
		}

		const formItems = myArry.map((item, index) => {
			const words = `notarialMatters${item.key}`
			const words1 = `notaryNumber${item.key}`
			return (
				<div className={styles.addDiv}>
					<Form key={item.key}>
					<Row gutter={24} span={24}>
						<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
							<FormItem
								label="公证事项："
								{...formItemLayout}>
								{getFieldDecorator(`notarialMatters${item.key}`, {
									initialValue: infoData ? this.state.value[words] ? this.state.value[words] : item.notarialMatters : '',

									// initialValue: item.notarialMatters ? item.notarialMatters : "",
									// rules: [{ required: true, message: '公证事项不能为空' }],
								})(
									<Input placeholder="请输入公证事项" />
								)}
							</FormItem>
						</Col>
						<Col lg={12} md={6} sm={8} xs={12}>
							<FormItem
								label="公证号："
								{...formItemLayout}>
								{getFieldDecorator(`notaryNumber${item.key}`, {
									initialValue: infoData ? this.state.value.notaryNumber ? this.state.value[words1] : item.notaryNumber : '',
									// initialValue: item.notaryNumber ? item.notaryNumber : "",
									// rules: [{ required: true, message: '公证号不能为空' }],
								})(
									<Input placeholder="请填写公证号" />
								)}
							</FormItem>
						</Col>
					</Row>
					{index == myArry.length - 1?
						<div className={styles.addIcon}>
						<Icon
							style={{ fontSize: 20 }}
							className="dynamic-delete-button"
							type="minus-circle-o"
							disabled={keys.length === 1}
							onClick={() => this.removeForm(item.key)}
						/>
					</div>:null}
					{/* {myArry.length > 1 ? (
						<div className={styles.addIcon}>
							<Icon
								style={{ fontSize: 20 }}
								className="dynamic-delete-button"
								type="minus-circle-o"
								disabled={keys.length === 1}
								onClick={() => this.removeForm(item.key)}
							/>
						</div>
					) : null} */}
					</Form>
				</div>

			);
		});

		const formItems1 = peopleArry.map((item, index) => {
			const words = `applyName${item.key}`
			const words1 = `idcard${item.key}`
			return (
				<div className={styles.addDiv}>
					<Form key={item.key}>
					<Row gutter={24} style={{ marginBottom: 8 }}>
						<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
							<FormItem
								label="申请人："
								{...formItemLayout}>
								{getFieldDecorator(`applyName${item.key}`, {
									initialValue: infoData ? this.state.value[words] ? this.state.value[words] : item.applyName : '',
									// initialValue: item.applyName,
									rules: [{ required: true, message: '申请人不能为空' }],
								})(
									<Input placeholder="请填写申请人" />
								)}
							</FormItem>
						</Col>
						<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
							<FormItem
								label="身份证："
								{...formItemLayout}>
								{getFieldDecorator(`idcard${item.key}`, {
									initialValue: infoData ? this.state.value[words1] ? this.state.value[words1] : item.idcard : '',
									// initialValue: item.idcard,
									rules: [{ required: true, message: '身份证不能为空' }],
								})(
									<Input placeholder="请填写身份证" />
								)}
							</FormItem>
						</Col>
					</Row>
					{index == peopleArry.length - 1?
						<div className={styles.addIcon}>
						<Icon
							style={{ fontSize: 20 }}
							className="dynamic-delete-button"
							type="minus-circle-o"
							disabled={keys.length === 1}
							onClick={() => this.removePersonForm(item.key)}
						/>
					</div>:null}
					{/* {peopleArry.length > 1 ? (
						<div className={styles.addIcon}>
							<Icon
								style={{ fontSize: 20 }}
								className="dynamic-delete-button"
								type="minus-circle-o"
								disabled={keys1.length === 1}
								onClick={() => this.removePersonForm(item.key)}
							/>
						</div>
					) : null} */}
					</Form>
				</div>

			);
		});




		if (details.document.documentBillList) {
			var pages = details.document.documentBillList
			for (let i = 0; i < pages.length; i++) {
				datas[i] = pages[i].name + "@" + pages[i].collectType
				const bottoms = [];
				if (imgList.length < pages.length) {
					imgList[i] = []
				}
				if (imgList[i].length == 0) {
					for (var j = 0; j < pages[i].billfileList.length; j++) {
						imgList[i][j] = { uid: j, status: 'done', url: baseUrl + pages[i].billfileList[j].url + "?token=" + sessionStorage.getItem("token") + "&" + "sys=1001", urls: pages[i].billfileList[j].url }
					}
				}
				propss[i] = {
					action: 'http://file.sip.feelbang.com/upload?token=' + sessionStorage.getItem("token") + "&" + "sys=1001",
					listType: 'picture-card',
					//解决preflight response
					fileList: imgList[i],
					headers: {
						"X-Requested-With": null
					},

					//	defaultFileList: [...fileList2],
					className: 'upload-list-inline',
					onChange: this.onUpdateChanges.bind(this, i),
				};

				if (pages[i].collectType != undefined) {
					var bot;
					if(pages[i].collectType == 'api'){
						bot = ["本地","拍照","扫描","录像"]
					}else{
						bot = pages[i].collectType.split("#")
					}
					
					bot.map((item, j) => {
						if (item == "拍照") {
							bottoms.push(
								<Button
									key={j}
									style={{ marginLeft: 10 }}
									onClick={this.bottomsClick.bind(this, i)}
									type="primary"
									size='default'>
									{item}
								</Button>
							)
						} else if (item == "本地") {
							bottoms.push(
								<Button
									style={{ marginLeft: 10 }}
									onClick={this.bottonClick.bind(this, i)}
									type="primary"
									size='default'>
									{item}
								</Button>
							)
						} else if (item == "扫描") {
							bottoms.push(
								<Button
									style={{ marginLeft: 10 }}
									onClick={this.bottonScanClick.bind(this, i)}
									type="primary"
									size='default'>
									{item}
								</Button>
							)
						}
						else {
							bottoms.push(
								<Button
									style={{ marginLeft: 10 }}
									type="primary"
									size='default'>
									{item}
								</Button>
							)
						}
					})
				}
				const uploads = "";
				photoPage.push(
					<div>
						<div style={{ display: "flex", justifyContent: "space-between", margin: "10px 20px", background: "#f4f4f4", lineHeight: "50px", borderRadius: 5 }}>
							<span style={{ marginLeft: 10, fontWeight: 600 }}>{i + 1}.{pages[i].name} [{imgList[i] ? imgList[i].length : "0"}条]</span>
							<div style={{ marginRight: 10 }}>
								<Button type="primary"
									onClick={this.bottonClick.bind(this, i)}
									style={{ border: "1px solid #DDDDDD", marginRight: 10, color: "black", backgroundImage: "linear-gradient(180deg,#fdfdfd 0%,#dddddd 98%)" }}>
									查看
								</Button>
								{bottoms}
							</div>
						</div>
						<div id={i} style={{ overflow: "scroll", height: "200px", margin: "0 40px", display: "none" }}>
							<div className="clearfix">
								<Upload
									{...propss[i]}
								>
									{uploadButton}
								</Upload>

							</div>

						</div>
					</div>
				)
			}

		}


		return (
			<Form>
				<div>
					<div className="steps-content" style={{ width: "60%", marginLeft: "20%", marginTop: 20 }}>
						<Row gutter={24} span={24}>
							<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
								<FormItem
									label="档案年度："
									{...formItemLayout}>
									{getFieldDecorator('documentYear', {
										initialValue: infoData ? infoData.document.documentYear : '',
										rules: [{ required: true, message: '档案年度不能为空' }],
									})(
										<Select
											style={{ width: '100%' }}
											placeholder="请档案年度"
										// onChange={this.handleChange1.bind(this)}
										//											onSelect={this.onSelect1.bind(this)}
										>
											{/* <Option key={department1[i].id} value={department1[i].id}>{department1[i].name}</Option> */}
											<Option key="2018" value="2018">2018</Option>
											<Option key="2017" value="2017">2017</Option>
											<Option key="2016" value="2016">2016</Option>
											<Option key="2015" value="2015">2015</Option>
											<Option key="2014" value="2014">2014</Option>
											<Option key="2013" value="2013">2013</Option>
											<Option key="2012" value="2012">2012</Option>
											<Option key="2011" value="2011">2011</Option>
											<Option key="2010" value="2010">2010</Option>
										</Select>
									)}
								</FormItem>
							</Col>
							<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
								<FormItem
									label="批次号："
									{...formItemLayout}>
									{getFieldDecorator('batchNumber', {
										initialValue: infoData ? infoData.document.batchNumber : '',
										rules: [{ required: true, message: '批次号不能为空' }],
									})(
										<Input placeholder="请输入批次号" />
									)}
								</FormItem>
							</Col>
						</Row>
						{formItems}
						<FormItem {...formItemLayoutWithOutLabel}>
							<Button type="dashed" onClick={this.addForm} style={{ width: '60%' }}>
								<Icon type="plus" /> 新增公证信息
								</Button>
						</FormItem>

						{formItems1}
						<FormItem {...formItemLayoutWithOutLabel}>
							<Button type="dashed" onClick={this.addPersonForm} style={{ width: '60%' }}>
								<Icon type="plus" /> 新增申请人
								</Button>
						</FormItem>
						{/* <Row gutter={24} style={{ marginBottom: 8 }}>
							<FormItem
								label="申请人："
								{...formItemLayout1}>
								{getFieldDecorator('applyName', {
									initialValue: infoData ? infoData.document.applyName : '',
									rules: [{ required: true, message: '申请人不能为空' }],
								})(
									<Input placeholder="请填写申请人" />
								)}
							</FormItem>
						</Row> */}

						<Row gutter={24} span={24}>
							<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
								<FormItem
									label="收件日期："
									{...formItemLayout}>
									{getFieldDecorator('createdTime', {
										// moment(this.state.value.notarizationAt,dateFormat)
										initialValue: infoData ? moment(formatDate(infoData.document.createdTime, dateFormat)) : "",
										rules: [{ required: true, message: '建档日期不能为空' }],
									})(
										<DatePicker
											style={{ width: "100%" }}
											placeholder="收件日期"
											showTime
											format="YYYY-MM-DD HH:00:00"
											onChange={this.createTimeChange}
										/>
									)}
								</FormItem>
							</Col>
							<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
								<FormItem
									label="公证日期："
									{...formItemLayout}>
									{getFieldDecorator('notarizationAt', {
										initialValue: infoData ? moment(formatDate(infoData.document.notarizationAt, dateFormat)) : "",
										rules: [{ required: true, message: '公证日期不能为空' }],
									})(
										<DatePicker
											style={{ width: "100%" }}
											placeholder="公证日期"
											showTime
											format="YYYY-MM-DD HH:00:00"
											onChange={this.notarizationChange}
										/>
									)}
								</FormItem>
							</Col>
						</Row>

						<Row gutter={24} style={{ marginBottom: 8 }}>
							<FormItem
								label="档案备注："
								{...formItemLayout1}>
								{getFieldDecorator('remarks', {
									initialValue: infoData ? infoData.document.remarks : "",
									// rules: [{ required: true, message: '申请人不能为空' }],
								})(
									<TextArea rows={4} />
								)}
							</FormItem>
						</Row>

						<div style={{ borderBottom: "1px dashed #d9d9d9", marginBottom: 32 }}></div>

						<div>
							<Row gutter={24} span={24} style={{ marginTop: 16 }}>
								<Col lg={12} md={6} sm={8} xs={12}>
									<FormItem
										label="保管期限："
										{...formItemLayout}>
										{getFieldDecorator('storageLife', {
											initialValue: infoData ? infoData.document.storageLife : "",
											rules: [{ required: true, message: '保管期限不能为空' }],
										})(
											<Select
												// disabled={infoData ? true : false}
												style={{ width: '100%' }}
												placeholder="请选择保管期限"
											>
												<Option key="长期">长期</Option>
												<Option key="短期">短期</Option>
											</Select>
										)}
									</FormItem>
								</Col>
								<Col lg={12} md={6} sm={8} xs={12}>
									<FormItem
										label="档案页数："
										{...formItemLayout}>
										{getFieldDecorator('pageNumber', {
											initialValue: infoData ? infoData.document.pageNumber : "",
											rules: [{ required: true, message: '档案页数不能为空' }],
										})(
											<Input placeholder="请填写档案页数" />
										)}
									</FormItem>
								</Col>
							</Row>

							{/* <Row gutter={24} style={{ marginBottom: 8 }}>
								<FormItem
									label="公证号："
									{...formItemLayout1}>
									{getFieldDecorator('notaryNumber', {
										initialValue: infoData ? infoData.document.notaryNumber : "",
										rules: [{ required: true, message: '公证号不能为空' }],
									})(
										<Input placeholder="请填写公证号" />
									)}
								</FormItem>
							</Row> */}

							<Row gutter={24} span={24}>
								<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
									<FormItem
										label="承办人："
										{...formItemLayout}>
										{getFieldDecorator('contractorUserId', {
											initialValue: infoData ? infoData.document.contractorUserId : "",
											rules: [{ required: true, message: '承办人不能为空' }],
										})(
											<Select
												style={{ width: '100%' }}
												placeholder="请选择承办人"
												// onChange={this.handleChange1.bind(this)}
												// onSelect={this.onSelect1.bind(this)}
											>
												{/* <Option key={department1[i].id} value={department1[i].id}>{department1[i].name}</Option> */}
												{userLists}
											</Select>
										)}
									</FormItem>
								</Col>
								<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 8 }}>
									<FormItem
										label="建档人："
										{...formItemLayout}>
										{getFieldDecorator('createdUserId', {
											initialValue: infoData ? infoData.document.createdUserId : "",
											rules: [{ required: true, message: '建档人不能为空' }],
										})(
											<Select
												style={{ width: '100%' }}
												placeholder="请选择建档人"
												// onSelect={this.onSelect2.bind(this)}
											>
												{/* <Option key={department2[i].id} value={department2[i].id}>{department2[i].name}</Option> */}
												{userLists}
											</Select>
										)}
									</FormItem>
								</Col>
							</Row>

							<Row gutter={24} span={24}>
								<Col lg={12} md={6} sm={8} xs={12} style={{ marginBottom: 16 }}>
									<FormItem
										label="卷宗类型："
										{...formItemLayout}>
										{getFieldDecorator('type', {
											initialValue: infoData ? infoData.document.dossierType : "",
											// rules: [{ required: true, message: '卷宗类型不能为空' }],
										})(
											<Select
												// disabled={infoData ? true : false}
												style={{ width: '100%' }}
												placeholder="请选择卷宗类型"
												disabled={true}
											// onChange={this.handleChange2.bind(this)}
											>
												{typeChild}
											</Select>
										)}
									</FormItem>
								</Col>
							</Row>
						</div>

					</div>

					{/* 拍照 */}
					<div style={{ width: "80%", marginLeft: "10%", marginTop: 20, display: "flex", marginBottom: 20 }}>
						<div style={{position:"absolute",width:"100%",lineHeight:"600px",textAlign:"center",zIndex:99999999,display:this.state.showLoading?"block":"none"}}><Icon style={{fontSize:160,color:"#1790ff"}} type="loading" /></div>	
						<div className="contentLeft" style={{ width: "60%", height: 600, borderRadius: 10, border: "1px dashed #d9d9d9", overflow: 'scroll' }}>
							{/* <div style={{ marginLeft: 20, marginTop: 10, margin: 20, display: "flex" }}>
								<span style={{ fontSize: 18 }}>扫描选择:</span>
								<Select style={{ marginLeft: 10, width: 160 }}>
									<Option key={1}>单面ADF扫描</Option>
									<Option key={2}>双面ADF扫描</Option>
								</Select>
								<Button
									style={{ marginLeft: 10 }}
									type="primary"
									size='default'>重置设备</Button>
							</div> */}
							<div style={{ marginLeft: 20, marginTop: 10, margin: 20 }}>
								<span style={{ fontSize: 18 }}>档案类型:</span>
								<Select style={{ marginLeft: 10, width: 160 }} defaultValue={details ? details.document.documentType : ""} onChange={this.selectChange}>
									<Option key="国内">国内</Option>
									<Option key="涉外">涉外</Option>
									<Option key="公证">公证</Option>
									<Option key="提存">提存</Option>
									<Option key="回收卷">回收卷</Option>
								</Select>
							</div>
							<div className="listLib">
								<span style={{ fontSize: 18, margin: 20 }}>资料清单:</span>
								{photoPage}
							</div>
						</div>

						<div className="contentRight" style={{ width: "40%", height: 600, borderRadius: 10, border: "1px dashed #d9d9d9", marginLeft: 20, display: "flex", justifyContent: "space-around", alignItems: "center", flexDirection: "column" }}>
							{this.state.showImg == false && this.state.showScanImg == false ?
								<div style={{ display: "flex", justifyContent: "center", alignItems: "center", flexDirection: "column", marginTop: 70 }}>
									<img src={require('../../../assets/photo.png')} style={{ width: 120, margin: 5 }} />
									<span>实时预览</span>
								</div>
								:
								this.state.showImg == true ?
									<div style={{ width: "80%", display: "flex", flexDirection: "column", justifyContent: "center", alignItems: "center" }}>
										<img id="myCanvas" style={{ height: 240, width: 320, marginBottom: 20, backgroundColor: "black", float: "left" }} />
										<div>
											<Button onClick={() => this.handleCaptureBase64()}>拍照Base64</Button>
											<Button onClick={this.handleOpenDev} style={{ marginLeft: 10 }}>开启摄像头</Button>
										</div>
									</div> :
									<div>
										<div style={{ overflow: "scroll" }}>
											{this.state.showImgList}
										</div>
										<div style={{ textAlign: "center", marginBottom: 20 }}>
											<Button onClick={() => this.handleOpenScan()}>启动扫描仪</Button>
											<Button onClick={this.handleScanBase64} style={{ marginLeft: 10 }}>扫描</Button>
										</div>
									</div>
							}
							<div style={{ textAlign: "center" }}>
								{this.state.showImg == false && this.state.showScanImg == false ?
									<div></div>
									:
									this.state.showImg == true ?
										<Button type="primary" style={{ marginBottom: 10 }} onClick={this.handleUpload}>
											拍照上传
	        							</Button> :
										<Button type="primary" style={{ marginBottom: 10 }} onClick={this.handleScanUpload}>
											扫描上传
	        							</Button>
								}
							</div>
						</div>
					</div>

					<div style={{ textAlign: "center" }}>
						<Button type="primary" onClick={this.agreeClick}>同意</Button>
						<Button onClick={this.disagreeClick} style={{ marginLeft: 10 }}>拒绝</Button>
					</div>
					<Button style={{ width: 200, marginTop: 30, height: 40 }} type="primary" onClick={this.showReturn.bind(this)}>返回</Button>
					<Modal visible={previewVisible} footer={null} onCancel={this.handleCancel}>
						<img alt="example" style={{ width: '100%' }} src={previewImage} />
					</Modal>
				</div>
			</Form>
		)
	}


}

export default Form.create()(ModalSelect)
